home *** CD-ROM | disk | FTP | other *** search
/ Precision Software Appli…tions Silver Collection 1 / Precision Software Applications Silver Collection Volume One (PSM) (1993).iso / windows / games / wmfread.arj / WMFDCODE.H < prev    next >
C/C++ Source or Header  |  1992-11-17  |  12KB  |  432 lines

  1. #include "commdlg.h"
  2. /* resource file for Windows Metafile Decoder */
  3.  
  4. #define  APPNAME         "Windows Metafile Decoder"  /* app name */
  5.  
  6. /* control IDs */
  7. #define  IDGO            99
  8. #define  IDE_RECNUM      100
  9. #define  IDE_RECSIZE     101
  10. #define  IDE_FUNCTION    102
  11. #define  IDL_PARAMETERS  103
  12.  
  13. #define  IDM_ABOUT       104
  14. #define  IDM_OPEN        105
  15. #define  IDM_ENUM        106
  16.  
  17. #define  IDC_FILENAME    107
  18. #define  IDC_EDIT        108
  19. #define  IDC_FILES       109
  20. #define  IDC_LISTBOX     110
  21. #define  IDC_PATH        111
  22.  
  23. #define  IDM_HEADER      112
  24. #define  IDS_VER         113
  25. #define  IDS_SIZE        114
  26. #define  IDS_OBJECTS     115
  27. #define  IDS_MAXREC      116
  28. #define  IDM_EXIT        117
  29. #define  IDM_ALLREC      118
  30. #define  IDM_GOTOREC     119
  31. #define  IDM_CLEAR       120
  32. #define  IDM_ENUMRANGE   121
  33. #define  IDE_FROM        122
  34. #define  IDE_TO          123
  35. #define  IDCB_ALL        124
  36. #define  IDL_PLAY        125
  37. #define  IDL_PRINT       126
  38. #define  IDM_LIST        127
  39. #define  IDL_LBREC       128
  40. #define  IDM_MM          129
  41. #define  IDE_EDITMM      130
  42. #define  IDCHANGE        131
  43. #define  IDQUITENUM      132
  44. #define  IDM_PRINT       133
  45. #define  IDM_CLIPHDR     134
  46. #define  IDM_ALDUSHDR    135
  47. #define  IDE_MM          136
  48. #define  IDE_XEXT        137
  49. #define  IDE_YEXT        138
  50. #define  IDE_HMF         139
  51.  
  52. #define  IDS_KEY         140
  53. #define  IDS_LEFT        141
  54. #define  IDS_RIGHT       142
  55. #define  IDS_TOP         143
  56. #define  IDS_BOT         144
  57. #define  IDS_INCH        145
  58. #define  IDS_CHKSUM      146
  59. #define  IDCB_SEL        147
  60. #define  IDCB_UNSEL      148
  61.  
  62. #define  IDM_DESTDISPLAY 149
  63. #define  IDM_DESTMETA    150
  64.  
  65. #define  IDB_HEX         151
  66. #define  IDB_DEC         152
  67. #define  IDB_CHAR        153
  68. #define  HEX             16
  69. #define  DEC             10
  70.  
  71. #define  WMFDISPLAY      0
  72. #define  WMFPRINTER      1
  73.  
  74. #define  IDM_VIEW        1
  75. #define  IDM_PLAY        2
  76.  
  77. #define  ENUMMFSTEP      0
  78. #define  ENUMMFLIST      1
  79.  
  80.  
  81.  
  82. #define  DESTDISPLAY     0
  83. #define  DESTMETA        1
  84. int      iDestDC;
  85.  
  86.  
  87. /* common dialog structures and constants */
  88.  
  89. #define MAXFILTERLEN 256
  90. #define FILEOPENDLG  0
  91. #define FILESAVEDLG  1
  92.  
  93. typedef struct tagFOCHUNK  {
  94.         OPENFILENAME of;
  95.         char szFile[256];
  96.         char szFileTitle[256];
  97. } FOCHUNK;
  98.  
  99. typedef FOCHUNK FAR *LPFOCHUNK;
  100. typedef FOCHUNK FAR *LPFSCHUNK; 
  101. typedef WORD (CALLBACK* FARHOOK)(HWND,UINT,WPARAM,LPARAM);
  102.  
  103. /* clipboard data definitions */
  104.  
  105. #define  CLP_ID          0xC350
  106.  
  107. /* clipboard file header */
  108. typedef struct {
  109.         WORD FileIdentifier;
  110.         WORD FormatCount;
  111. } CLIPFILEHEADER;
  112.  
  113. /* clipboard format header */
  114. typedef struct {
  115.         WORD  FormatID;
  116.         DWORD DataLen;
  117.         DWORD DataOffset;
  118.         char  Name[79];
  119. } CLIPFILEFORMAT;
  120.  
  121. /* placeable metafile data definitions */
  122.  
  123. #define  ALDUSKEY        0x9AC6CDD7
  124.  
  125. /* placeable metafile header */
  126. typedef struct {
  127.         DWORD   key;
  128.         HANDLE  hmf;
  129.         RECT    bbox;
  130.         WORD    inch;
  131.         DWORD   reserved;
  132.         WORD    checksum;
  133. }ALDUSMFHEADER;
  134.  
  135. /* metafile function table lookup data definitions */
  136.  
  137. #define  NUMMETAFUNCTIONS 71
  138.  
  139. typedef struct tagMETAFUNCTIONS {
  140.         char *szFuncName;
  141.         WORD value;
  142. } METAFUNCTIONS;
  143.  
  144. typedef WORD FAR *LPPARAMETERS;
  145.  
  146.  
  147. /* global vars for main module */
  148.  
  149. #ifdef MAIN
  150.  
  151. HANDLE hInst;
  152. HANDLE CurrenthDlg;
  153. HANDLE hSaveCursor;
  154. HWND   hWndMain;
  155. HWND   hWndList;
  156.  
  157. LPPARAMETERS lpMFParams;
  158. HANDLE hMem;
  159. HANDLE hSelMem;
  160. int FAR *lpSelMem;
  161.  
  162. FARPROC lpWMFRecDlgProc;
  163. FARPROC lpprocEnumMF;
  164. FARPROC lpPlayFromListDlgProc;
  165. FARPROC lpProcAbout;
  166. FARPROC lpClpHeaderDlg;
  167. FARPROC lpHeaderDlg;
  168. FARPROC lpAldusHeaderDlg;
  169. FARPROC lpEnumRangeDlg;
  170. FARPROC lpListDlgProc;
  171.  
  172. //flags
  173.  
  174. BOOL bInPaint;
  175. BOOL bPlayRec;
  176. BOOL bPlayItAll;
  177. BOOL bBadFile      = FALSE;
  178. BOOL bValidFile    = FALSE;
  179. BOOL bMetaFileOpen = FALSE;
  180. BOOL bMetaInRam    = FALSE;
  181. BOOL bAldusMeta    = FALSE;
  182. BOOL bPlayList     = FALSE;
  183. BOOL bPlaySelList  = TRUE;
  184. BOOL bEnumRange;
  185.  
  186. int  iEnumAction;
  187. int  iStartRange;
  188. int  iEndRange;
  189.  
  190. DWORD iCount = 0;               //index into lpSelMem
  191. DWORD iNumSel = 0;               //number of listbox selections
  192.  
  193.  
  194. //common fo dialog vars
  195.  
  196. char gszFilter[MAXFILTERLEN]="MetaFiles\0*.WMF;*.CLP\0";
  197. char gszBuffer[MAXFILTERLEN];
  198. int  nFileOffset;
  199. int  nExtOffset;
  200.  
  201. //file io related vars
  202.  
  203. char                  OpenName[144];
  204. char                  SaveName[144];
  205. char                  str[255];
  206. OFSTRUCT              ofStruct;
  207. DWORD                 iLBItemsInBuf;
  208. char                  fnameext[20];
  209.  
  210. //metafile related vars
  211.  
  212. HANDLE                hMF;
  213. METAFILEPICT          MFP;
  214. METARECORD            MetaRec;
  215. METAHEADER            mfHeader;
  216. ALDUSMFHEADER         aldusMFHeader;
  217. WORD                  iRecNum = 0;
  218.  
  219. /* lookup table for metafile functions */
  220.  
  221. METAFUNCTIONS MetaFunctions[] = {
  222.  
  223.      "SETBKCOLOR",           0x0201,
  224.      "SETBKMODE",            0x0102,
  225.      "SETMAPMODE",           0x0103,
  226.      "SETROP2",              0x0104,
  227.      "SETRELABS",            0x0105,
  228.      "SETPOLYFILLMODE",      0x0106,
  229.      "SETSTRETCHBLTMODE",    0x0107,
  230.      "SETTEXTCHAREXTRA",     0x0108,
  231.      "SETTEXTCOLOR",         0x0209,
  232.      "SETTEXTJUSTIFICATION", 0x020A,
  233.      "SETWINDOWORG",         0x020B,
  234.      "SETWINDOWEXT",         0x020C,
  235.      "SETVIEWPORTORG",       0x020D,
  236.      "SETVIEWPORTEXT",       0x020E,
  237.      "OFFSETWINDOWORG",      0x020F,
  238.      "SCALEWINDOWEXT",       0x0400,
  239.      "OFFSETVIEWPORTORG",    0x0211,
  240.      "SCALEVIEWPORTEXT",     0x0412,
  241.      "LINETO",               0x0213,
  242.      "MOVETO",               0x0214,
  243.      "EXCLUDECLIPRECT",      0x0415,
  244.      "INTERSECTCLIPRECT",    0x0416,
  245.      "ARC",                  0x0817,
  246.      "ELLIPSE",              0x0418,
  247.      "FLOODFILL",            0x0419,
  248.      "PIE",                  0x081A,
  249.      "RECTANGLE",            0x041B,
  250.      "ROUNDRECT",            0x061C,
  251.      "PATBLT",               0x061D,
  252.      "SAVEDC",               0x001E,
  253.      "SETPIXEL",             0x041F,
  254.      "OFFSETCLIPRGN",        0x0220,
  255.      "TEXTOUT",              0x0521,
  256.      "BITBLT",               0x0922,
  257.      "STRETCHBLT",           0x0B23,
  258.      "POLYGON",              0x0324,
  259.      "POLYLINE",             0x0325,
  260.      "ESCAPE",               0x0626,
  261.      "RESTOREDC",            0x0127,
  262.      "FILLREGION",           0x0228,
  263.      "FRAMEREGION",          0x0429,
  264.      "INVERTREGION",         0x012A,
  265.      "PAINTREGION",          0x012B,
  266.      "SELECTCLIPREGION",     0x012C,
  267.      "SELECTOBJECT",         0x012D,
  268.      "SETTEXTALIGN",         0x012E,
  269.      "DRAWTEXT",             0x062F,
  270.      "CHORD",                0x0830,
  271.      "SETMAPPERFLAGS",       0x0231,
  272.      "EXTTEXTOUT",           0x0a32,
  273.      "SETDIBTODEV",          0x0d33,
  274.      "SELECTPALETTE",        0x0234,
  275.      "REALIZEPALETTE",       0x0035,
  276.      "ANIMATEPALETTE",       0x0436,
  277.      "SETPALENTRIES",        0x0037,
  278.      "POLYPOLYGON",          0x0538,
  279.      "RESIZEPALETTE",        0x0139,
  280.      "DIBBITBLT",            0x0940,
  281.      "DIBSTRETCHBLT",        0x0b41,
  282.      "DIBCREATEPATTERNBRUSH",0x0142,
  283.      "STRETCHDIB",           0x0f43,
  284.      "DELETEOBJECT",         0x01f0,
  285.      "CREATEPALETTE",        0x00f7,
  286.      "CREATEBRUSH",          0x00F8,
  287.      "CREATEPATTERNBRUSH",   0x01F9,
  288.      "CREATEPENINDIRECT",    0x02FA,
  289.      "CREATEFONTINDIRECT",   0x02FB,
  290.      "CREATEBRUSHINDIRECT",  0x02FC,
  291.      "CREATEBITMAPINDIRECT", 0x02FD,
  292.      "CREATEBITMAP",         0x06FE,
  293.      "CREATEREGION",         0x06FF,
  294. };
  295.  
  296. /* printer variables */
  297.  
  298. HDC                   hPr;                 // handle for printer device context
  299. POINT                 PhysPageSize;        // information about the page
  300. BOOL                  bAbort;              // FALSE if user cancels printing
  301. HWND                  hAbortDlgWnd;
  302. FARPROC               lpAbortDlg;
  303. FARPROC               lpAbortProc;
  304.  
  305. #endif /* if defined MAIN */
  306.  
  307. /* externs for modules other than main module */
  308.  
  309. #ifndef MAIN
  310.  
  311. extern HANDLE         hInst;
  312. extern HANDLE         CurrenthDlg;
  313. extern HANDLE         hSaveCursor;
  314. extern HWND           hWndMain;
  315. extern HWND           hWndList;
  316.  
  317. extern LPPARAMETERS   lpMFParams;
  318. extern HANDLE         hMem;
  319. extern HANDLE         hSelMem;
  320. extern int FAR        *lpSelMem;
  321.  
  322. extern FARPROC        lpWMFRecDlgProc;
  323. extern FARPROC        lpprocEnumMF;
  324. extern FARPROC        lpPlayFromListDlgProc;
  325.  
  326. //flags
  327.  
  328. extern BOOL           bInPaint;
  329. extern BOOL           bPlayRec;
  330. extern BOOL           bPlayItAll;
  331. extern BOOL           bBadFile;
  332. extern BOOL           bValidFile;
  333. extern BOOL           bMetaFileOpen;
  334. extern BOOL           bMetaInRam;
  335. extern BOOL           bAldusMeta;
  336. extern BOOL           bPlayList;
  337. extern BOOL           bPlaySelList;
  338. extern BOOL           bEnumRange;
  339.  
  340. extern int            iEnumAction;
  341. extern int            iStartRange;
  342. extern int            iEndRange;
  343.  
  344. extern DWORD          iCount;              //index into lpSelMem
  345. extern DWORD          iNumSel;             //number of listbox selections
  346.  
  347. //common dialog vars
  348.  
  349. extern char gszFilter[MAXFILTERLEN];
  350. extern char gszBuffer[MAXFILTERLEN];
  351. extern int  nFileOffset;
  352. extern int  nExtOffset;
  353.  
  354. //file io related vars
  355.  
  356. extern char           OpenName[144];
  357. extern char           SaveName[144];
  358. extern char           str[256];
  359. extern OFSTRUCT       ofStruct;
  360. extern DWORD          iLBItemsInBuf;
  361. extern char           fnameext[20];
  362.  
  363. //metafile related vars
  364.  
  365. extern HANDLE         hMF;
  366. extern METAFILEPICT   MFP;
  367. extern METARECORD     MetaRec;
  368. extern METAHEADER     mfHeader;
  369. extern ALDUSMFHEADER  aldusMFHeader;
  370. extern WORD           iRecNum;
  371. extern METAFUNCTIONS  MetaFunctions[];
  372.  
  373. //printer variables
  374.  
  375. extern HDC            hPr;                 // handle for printer device context
  376. extern POINT          PhysPageSize;        // information about the page
  377. extern BOOL           bAbort;              // FALSE if user cancels printing
  378. extern HWND           hAbortDlgWnd;
  379. extern FARPROC        lpAbortDlg;
  380. extern FARPROC        lpAbortProc;
  381.  
  382. #endif /* if !defined MAIN */
  383.  
  384. /* function prototypes */
  385.  
  386. /* WMFDCODE.C */
  387.  
  388. int    PASCAL WinMain(HANDLE, HANDLE, LPSTR, int);
  389. BOOL   InitApplication(HANDLE);
  390. BOOL   InitInstance(HANDLE, int);
  391. long   FAR PASCAL MainWndProc(HWND, UINT, WPARAM, LPARAM);
  392. HANDLE FAR PASCAL OpenDlg(HWND, unsigned, WORD, LONG);
  393. void   WaitCursor(BOOL);
  394.  
  395. /* WMFMETA.C */
  396.  
  397. int    FAR PASCAL MetaEnumProc(HDC, LPHANDLETABLE, LPMETARECORD, int, BYTE FAR *);
  398. void   GetMetaFileAndEnum(HDC);
  399. BOOL   LoadParameterLB(HWND, DWORD, int);
  400. BOOL   PlayMetaFileToDest(HWND, int);
  401. BOOL   RenderClipMeta(CLIPFILEFORMAT *, int);
  402. BOOL   RenderPlaceableMeta(int);
  403. void   SetPlaceableExts(HDC, ALDUSMFHEADER, int);
  404. VOID   SetClipMetaExts(HDC, METAFILEPICT, int);
  405. BOOL   ProcessFile(HWND, LPSTR);
  406.  
  407. /* DLGPROC.C */
  408.  
  409. BOOL FAR PASCAL WMFRecDlgProc(HWND, unsigned, WORD, LONG);
  410. BOOL FAR PASCAL HeaderDlgProc(HWND, unsigned, WORD, LONG);
  411. BOOL FAR PASCAL ClpHeaderDlgProc(HWND, unsigned, WORD, LONG);
  412. BOOL FAR PASCAL AldusHeaderDlgProc(HWND, unsigned, WORD, LONG);
  413. BOOL FAR PASCAL EnumRangeDlgProc(HWND, unsigned, WORD, LONG);
  414. BOOL FAR PASCAL ListDlgProc(HWND, unsigned, WORD, LONG);
  415. BOOL FAR PASCAL PlayFromListDlgProc(HWND, unsigned, WORD, LONG);
  416. BOOL FAR PASCAL MMDlgProc(HWND, unsigned, WORD, LONG);
  417. BOOL FAR PASCAL About(HWND, unsigned, WORD, LONG);
  418.  
  419. /* WMFPRINT.C */
  420.  
  421. BOOL   PrintWMF(void);
  422. HANDLE GetPrinterDC(void);
  423. int    FAR PASCAL AbortDlg(HWND, unsigned, WORD, LONG);
  424. int    FAR PASCAL AbortProc(HDC, int);
  425.  
  426. /* CMNDLG.C */
  427.  
  428. void InitializeStruct(WORD, LPSTR);
  429. int  OpenFileDialog(LPSTR);
  430. int  SaveFileDialog(LPSTR);
  431. void SplitPath( LPSTR, LPSTR, LPSTR, LPSTR, LPSTR);
  432.